package com.talkweb.calendarview.slice;

import com.talkweb.calendarview.Calendar;
import com.talkweb.calendarview.CalendarView;
import com.talkweb.calendarview.ResourceTable;
import com.talkweb.calendarview.simple.SimpleCalendarAbility;
import ohos.aafwk.ability.AbilitySlice;
import ohos.aafwk.content.Intent;
import ohos.aafwk.content.Operation;
import ohos.agp.components.Component;

public class MainAbilitySlice extends AbilitySlice {
    CalendarView calendarView;

    @Override
    public void onStart(Intent intent) {
        super.onStart(intent);
        super.setUIContent(ResourceTable.Layout_ability_custom);
//        super.setUIContent(ResourceTable.Layout_ability_simple);
//        super.setUIContent(ResourceTable.Layout_ability_main);
//
//        findComponentById(ResourceTable.Id_text).setClickedListener(new Component.ClickedListener() {
//            @Override
//            public void onClick(Component component) {
//                Intent intent = new Intent();
//                intent.setElementName(getBundleName(), SimpleCalendarAbility.class.getName());
//                startAbility(intent);
//            }
//        });
        calendarView = (CalendarView) findComponentById(ResourceTable.Id_calendarView);
        findComponentById(ResourceTable.Id_bt_year).setClickedListener(component -> {
            calendarView.showYearSelectLayout(2021);
        });
        Calendar calendar = getSchemeCalendar(2021, 3, 4, 0xFF40db25, "");
        calendar.addScheme(0xFFFFdb25,"A");
        calendarView.addSchemeDate(calendar);


        findComponentById(ResourceTable.Id_container).setClickedListener(new Component.ClickedListener() {
            @Override
            public void onClick(Component component) {
                System.out.println("点击内容～～～～～～");
            }
        });
    }


    private Calendar getSchemeCalendar(int year, int month, int day, int color, String text) {
        Calendar calendar = new Calendar();
        calendar.setYear(year);
        calendar.setMonth(month);
        calendar.setDay(day);
        calendar.setSchemeColor(color);//如果单独标记颜色、则会使用这个颜色
        calendar.setScheme(text);
        return calendar;
    }

    @Override
    public void onActive() {
        super.onActive();
    }

    @Override
    public void onForeground(Intent intent) {
        super.onForeground(intent);
    }
}
